package com.woniuxy.third.service.impl;

import com.woniuxy.third.entity.subject.FirstSubject;
import com.woniuxy.third.entity.subject.SecondSubject;
import com.woniuxy.third.mapper.SubjectMapper;
import com.woniuxy.third.service.EduSubjectService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class EduSubjectServiceImpl implements EduSubjectService {
    @Resource
    private SubjectMapper subjectMapper;
    @Override
    public List<FirstSubject> getAllFirstSecondSubject() {
        //查询所有一二级学科并封装
        List<FirstSubject> allFirstSubject = subjectMapper.findAllFirstSubject(0);
        System.out.println(allFirstSubject);
        for (FirstSubject firstsubject:allFirstSubject
             ) {
            List<SecondSubject> allSecondSubject = subjectMapper.findAllSecondSubject(firstsubject.getId());
            firstsubject.setChildren(allSecondSubject);
        }
        return allFirstSubject;
    }
}
